package com.wu.web.service.impl;

import com.wu.web.dao.UserDao;
import com.wu.web.entity.TUser;
import com.wu.web.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author wuyanshen
 * @date 2019-01-02 2:13 PM
 * @discription 用户业务类
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;


    @Cacheable(value = "userCache")
    @Override
    public TUser findUser(String id) {
        TUser user = userDao.get(id);
        return user;
    }

    @CacheEvict(value = "userCache", allEntries = true)
    @Override
    public void addUser(TUser tUser) {
        userDao.insert(tUser);
    }
}
